<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>发射站组管理</title>
    <meta name="decorator" content="nblank"/>
    <%@include file="/WEB-INF/views/include/treetable.jsp" %>
</head>
<body>
<div class="content container">
    <h2 class="page-title">发射站组管理
        <small> 发射站列表</small>
    </h2>
    <section class="widget">
        <div class="body">
            <table id="treeTable" class="table table-hover  table-condensed">
                <thead class="menu-th">
                <tr>
                    <th>机构名称</th>
                    <th>地址</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="treeTableList"></tbody>
            </table>
        </div>
    </section>
</div>

<script type="text/javascript">
    $(function () {
        var leval = 0;
        var stationTypes =${fns:getDictListJson("station_type")};
        var stationEType2 =${fns:getDictListJson("station_e_type")};
        var data = ${fns:toJson(list)}, rootId = "${not empty office.id ? office.id : '0'}";
        addRow("#treeTableList", data, rootId, true);
        $("#treeTable").treeTable({expandLevel: 5});

        function addRow(list, data, pid, root) {
            leval++;
            for (var i = 0; i < data.length; i++) {
                var row = data[i];
                if ((${fns:jsGetVal('row.office.parentId')}) == pid) {
                    $(list).append(getTableRow(row, (root ? 0 : pid), leval));
                    addRow(list, data, row.office.id);
                }
            }
            leval--;
        }

        function getTableRow(row, pid, leval) {
            var r = '	<tr id="' + row.office.id + '" pId="' + pid + '">' +
                    '       <td>' + row.office.name + '</td>' +
                    '		<td>' + (row.address ? row.address : '') + '</td>' +
                    '		<td>' +
                    (leval == 4 ? ' <a href="${ctx}/biz/sgroup?station.id=' + (row.id ? row.id : '')  + '">组</a>' : '') +
                    '		</td>' +
                    '	</tr>';
            return r;
        }
    });

</script>
</body>
</html>